﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ForgotPassword.aspx.cs" Inherits="SIPO.Web.Forms.Authentication.ForgotPassword" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.wrapper.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.inputmask.bundle.min.js") %>" type="text/javascript"></script>
    <title>Forgot Password</title>
    <script type="text/javascript">

        $(document).ready(function () {

            $("#btnSend").button({ icons: { primary: "ui-icon-key"} });

        });

    </script>
    <script type="text/javascript">

        $(document).ready(function () {

            $("#txtEmail").inputmask("Regex", { regex: "[A-Za-z_.@0-9_]*" });

            var rules = {
                txtEmail: {
                    required: true,
                    email: true
                }
            };
            var messages = {
                txtEmail: {
                    required: "Email harus di isi!",
                    email: "Format email belum benar!"
                }
            };

            var validator = new jQueryValidatorWrapper("form1", rules, messages);

            $("#btnSend").click(function () {

                if (!validator.validate())
                    return;
                else {

                    $("#btnSend").hide();
                    var Email = $('#txtEmail').val();
                    var objrecForgotPassword = new Object();

                    objrecForgotPassword.email = encodeURIComponent(Email);

                    jsonData = JSON.stringify(objrecForgotPassword);

                    var handlerUrl = '<%= ResolveUrl("~/ajaxhandler/authentication/forgotpasswordhandler.ashx") %>'

                    $.ajax({
                        type: 'POST',
                        url: handlerUrl,
                        contentType: 'application/json',
                        dataType: 'json',
                        data: jsonData,
                        success: function (data) {

                            alert(data.Message);

                            if (data.IsValid == 1) {
                                parent.$('#dialog1').dialog('close');

                            }
                            $("#btnSend").show();

                        },
                        error: function (response) {
                            var r = JSON.parse(response.responseText);
                            alert("Error Message: " + r.Message);
                        }
                    });
                }

                return false;
            });

        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table width="100%">
            <tr>
                <td width="38%">
                    Masukkan Alamat Email Anda
                </td>
                <td>
                    :
                </td>
                <td>
                    <asp:TextBox ID="txtEmail" runat="server"
                        Height="17px"></asp:TextBox>
                </td>
                <td>
                    <button id="btnSend" type="button">
                        Kirim Sandi</button>
                </td>
            </tr>
        </table>
        <br />
    </div>
    </form>
</body>
</html>
